<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<base href="${pageContext.request.contextPath }/"> 
<title>CPI大数据采集及编辑</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
	function datachild(){
		$.ajax({
			type : "get",
			url : "DataTypeServlet?parentid=" + $("#datatypeparent").val(),
			async : true,
			dataType : "json",
			success : cpidatatype,
			error : errorinfo
		});
	}
	function cpidatatype(data) {
		var str="";
		$(data).each(function(i) {
		    if (data[i].datatypeid == "${cpidatamodel.dt.datatypeid}")
				str += "<option value='"+data[i].datatypeid+"' selected='selected'>"
						+ data[i].datatypename + "</option>";
			else 
			str+="<option value='"+data[i].datatypeid+"'>"+data[i].datatypename+"</option>";
		});
		$("#mydatatype").html(str);
	}
	function errorinfo() {
		alert("请求服务器失败");
	}
	$(function() {
		datachild();
	});
</script>
</head>
<body>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="153" height="48"><img
				src="images/projectmanager.gif"
				width="153" height="48"></td>
			<td
				background="images/maintitle-bg.gif">&nbsp;</td>
			<td width="80"><img
				src="images/maintitle-right.gif"
				width="80" height="48"></td>
		</tr>
	</table>
	<form id="form1" name="form1" action="UpCpiDataServlet?id=${cpidatamodel.cd.id }" method="post">
		<input type="hidden" id="id" name="id" value="" />
		<input type="hidden" id="pageIndex" name="id" value="" />
		<table width="100%" border="0" cellspacing="5" cellpadding="0"
			class="message">
			<tbody>
				<tr>
					<td height="35" align="right">CPI数据父类：</td>
					<td id="addparent">
						<select id="datatypeparent" name="datatypeparent"
							class="input-text-sytle98" onChange="datachild()">
								<c:forEach items="${datatype}" var="item">
									<c:choose>
										<c:when test="${item.datatypeid eq  cpidatamodel.dt.parentid}">
											<option value="${item.datatypeid}" selected="selected">${item.datatypename}</option>
										</c:when>
										<c:otherwise>
											<option value="${item.datatypeid}">${item.datatypename}</option>
										</c:otherwise>
									</c:choose>
	                			</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td height="35" align="right">CPI数据子类：</td>
					<td id="childtd">
						<select id="mydatatype" name="mydatatype" class="input-text-sytle98" onchange="addchild();">
						</select>
					</td>
				</tr>
				<tr>
					<td width="180" height="35" align="right">数据来源区域：</td>
					<td id="areatd">
						<select id="mydataarea" name="mydataarea" onchange="addarea();" class="input-text-sytle98">
							<c:forEach items="${areatype}" var="item">
								<c:choose>
									<c:when test="${item.areaid eq cpidatamodel.at.areaid }">
										<option value="${item.areaid}" selected="selected">${item.areaname}</option>
									</c:when>
									<c:otherwise>
										<option value="${item.areaid}">${item.areaname}</option>
									</c:otherwise>
								</c:choose>
                			</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td height="35" align="right">数据来源时间：</td>
					<td><input class="input-text-sytle98" id="cpidate" name="cpidate" type="date" required value="${cpidatamodel.cd.ontime }"></td>
				</tr>
				<tr>
					<td height="35" align="right">价格：</td>
					<td><input type="number" min="0" step="0.1" name="cpidata" id="cpidata"
						value="${cpidatamodel.cd.cpidata }"
						class="input-text-sytle98" required placeholder="请输入价格"></td>
				</tr>
				<tr>
					<td height="35" align="right">数据单位：</td>
					<td><select id="databit" name="databit"
						class="input-text-sytle98">
							<option value="500克">500克</option>
							<option value="个">个</option>
							<option value="盒">盒</option>
					</select></td>
				</tr>
 
				<tr>
					<td height="35" align="right" valign="top">备注：</td>
					<td><textarea name="demo" id="demo"
							class="input-text-sytle2010">${cpidatamodel.cd.demo }</textarea></td>
				</tr>
				<tr>
					<td id="info" height="35" align="right" style="color:red;font-size: 12px;"><span id="info">${info}</span></td>
					<td><input name="button" type="submit" class="submitbutton"
						value="保    存" onclick="return check()" /> <input name="button"
						type="button" class="submitbutton" onclick="location.href='CpiDataListServlet';"
						value="返    回" /></td>
				</tr>
				<tr><td></td><td><div style="color:red;"></div></td></tr>
			</tbody>
		</table>
	</form>
</body>
</html>
